package com.cysyz.mylib.dao.sqlcondspopulater.impl;


import com.cysyz.mylib.dao.sqloperaterrevolver.impl.BigEqualOperatorRevolver;
import com.cysyz.mylib.dao.sqloperaterrevolver.impl.InCsvValueOperatorRevolver;
import com.cysyz.mylib.dao.sqloperaterrevolver.impl.LessEqualOperatorRevolver;
import com.cysyz.mylib.dao.sqloperaterrevolver.impl.LikeOperatorRevolver;

import java.util.List;

/**
 * Created by emall on 2014/7/29.
 */
public class CommonMultiCondsPopulaterImpl extends SqlCondsPopulaterImpl {

    public CommonMultiCondsPopulaterImpl(StringBuilder sqlBuilder, List<Object> params) {
        this(sqlBuilder, params, false);
    }

    public CommonMultiCondsPopulaterImpl(StringBuilder sqlBuilder, List<Object> params, boolean sqlHasWhere) {
        super(sqlBuilder, params, sqlHasWhere);
    }

    @Override
    protected void setSqlOperators() {
        sqlOperatorRevolvers.add(new BigEqualOperatorRevolver());
        sqlOperatorRevolvers.add(new LessEqualOperatorRevolver());
        sqlOperatorRevolvers.add(new InCsvValueOperatorRevolver());
        sqlOperatorRevolvers.add(new LikeOperatorRevolver());
        super.setSqlOperators();
    }

    /**
     *
     * @param column
     * @param operator 操作符
     * @param value
     */
    public void addCond(String column, String operator, Object value) {
        if (value != null) {
            if (value instanceof String && ((String) value).isEmpty()) {
                return;
            }
            super.addCond(column, operator, value);
        }
    }

}
